local qiaomeng = fk.CreateSkill{
    name = "SP_heg__qiaomeng",
}

Fk:loadTranslationTable{
    ["SP_heg__qiaomeng"] = "趫猛",
    [":SP_heg__qiaomeng"] = "结束阶段，你可以使用一张【杀】，此【杀】目标为你距离其为1的所有其他势力角色。",
    ["#SP_heg__qiaomeng-usecard"] = "是否发动 趫猛 使用一张【杀】？（目标会在选择后被修改）",

    ["$SP_heg__qiaomeng1"] = "观今天下，何有我义从之敌。",
    ["$SP_heg__qiaomeng2"] = "众将征战所得，皆为汝等所有。",
}

local H = require "packages.ol_hegemony.util"

qiaomeng:addEffect(fk.EventPhaseStart,{
    anim_type = "offensive",
    can_trigger = function(self, event, target, player, data)
        return target == player and player:hasSkill(qiaomeng.name) and player.phase == Player.Finish
      end,
    on_cost= function (self, event, target, player, data)
        local room = player.room
        local card = Fk:cloneCard("slash")
        local to = player
        card.skillName = qiaomeng.name
        local targets = table.filter(room:getOtherPlayers(to), function (p)
          return to:compareDistance(p, 2, "<") and to:canUseTo(card, p, {bypass_times = true}) and not H.compareKingdomWith(p, player)
        end)
        if #targets > 0 then
        local use = room:askToUseCard(player,{
            skill_name = qiaomeng.name,
            pattern = "slash",
            prompt = "#SP_heg__qiaomeng-usecard",
            extra_data = {bypass_times = true},
            cancelable = true,
        })
         if use then
         event:setCostData(self,{use = use})
            return true
          end
        end
      end,
      on_use = function(self, event, target, player, data)
        local room = player.room
        local use = event:getCostData(self).use
        local card = use.card
        local to = player
        local targets = table.filter(room:getOtherPlayers(to), function (p)
          return to:compareDistance(p, 2, "<") and to:canUseTo(card, p, {bypass_times = true}) and not H.compareKingdomWith(p, player)
        end)
        if #targets > 0 then
        room:sortByAction(targets)
        use.tos = targets
        room:useCard(use)
       end
    end,
})

return qiaomeng